package org.springboot.sample.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 
 * @author estcele
 *
 */
@RestController
@RequestMapping("/hello")
public class HelloController {
	/**
	 * 
	 * @return
	 */
	@RequestMapping
	public String hello() {
		return "Hello Spring-Boot";
	}

	/**
	 * 
	 * @param name
	 * @return
	 */
	@RequestMapping("/info")
	public Map<String, String> getInfo(@RequestParam String name) {
		Map<String, String> map = new HashMap<>();
		map.put("name", name);
		return map;
	}
	
	/**
	 * 
	 * @return
	 */
	@RequestMapping("/list/{count}")
	public List<Map<String,String>> getList(@PathVariable int count) {
		List<Map<String, String>> list = new ArrayList<>();
		Map<String, String> map = null;
		for (int i = 1; i <= count; i++) {
			map = new HashMap<>();
			map.put("name", "Shanhy-" + i);
			list.add(map);
		}
		return list;
	}
}
